package lab01.Text8;

import javax.swing.*;

public class GuessNumber {
    public static void main (String args[])
    {
        System.out.println("give you an integer between 1 and 100,please guess the number");
        int realNumber=(int)(Math.random()*100)+1;
        int yourGuess=0;
        String str=JOptionPane.showInputDialog("enter the number:");
        yourGuess=Integer.parseInt(str);
        //循环条件
        while(yourGuess!=realNumber)
        {
            //条件代码
            if(yourGuess>realNumber)
            {
                str= JOptionPane.showInputDialog("guess big,please enter the number again:");
                yourGuess=Integer.parseInt(str);
            }
            else if(yourGuess==realNumber)
            {
                str=JOptionPane.showInputDialog("guess small,please enter the number again:");
                yourGuess=Integer.parseInt(str);
            }
        }
        System.out.println("guess right!");
    }
    }
